package com.blrs.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.core.page.TableDataInfo;
import com.blrs.domain.ProcessStage;
import com.blrs.service.process.IProcessStageService;

@RestController
@RequestMapping("/process/stage")
public class ProcessStageController extends BaseController {
    @Autowired
    private IProcessStageService processStageService;

    @GetMapping("/list")
    public TableDataInfo list(ProcessStage processStage) {
        startPage();
        List<ProcessStage> list = processStageService.selectProcessStageList(processStage);
        return getDataTable(list);
    }

    @GetMapping("/template/{templateId}")
    public AjaxResult listByTemplateId(@PathVariable("templateId") String templateId) {
        return success(processStageService.selectProcessStagesByTemplateId(templateId));
    }

    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(processStageService.selectProcessStageById(id));
    }

    @PostMapping
    public AjaxResult add(@RequestBody ProcessStage processStage) {
        return toAjax(processStageService.insertProcessStage(processStage));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody ProcessStage processStage) {
        return toAjax(processStageService.updateProcessStage(processStage));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(processStageService.deleteProcessStageByIds(ids));
    }
} 